<template>
  <view class="container">
    <view class="main">
      <view class="amountInfo">
        <view class="amountInfo-title">
          <text style="color: red;">*</text>反馈内容
        </view>
        <textarea class="autn-item-ipt" style="height: 280rpx;padding: 30rpx;box-sizing: border-box;" v-model="formLine.content" placeholder-class="styles" type="text"
          placeholder="请输入" />
      </view>
      <view class="amountInfo">
        <view class="amountInfo-title" style="margin-bottom: 15rpx;">
          <text style="color: red;">*</text>反馈图片({{formLine.images.length}}/9)
        </view>
        <view class="imgs">
          <UploadImgs keyName="images" :uploadImg="formLine.images" @getUrl="getUrls" />
        </view>
      </view>
    </view>
    <view class="footer">
      <view class="btn" @click="onSave">提交</view>
    </view>
  </view>
</template>

<script>
  import reqApi from "../../api/api.js";
  export default {
    data() {
      return {
        formLine: {
          content: "",
          images: [],
        },
      }
    },
    methods: {
      async onSave() {
        if (!this.formLine.content) {
          uni.showToast({
            title: "内容不能为空",
            icon: 'none',
            mask: true,
            duration: 1500,
          })
          return
        }
        if (this.formLine.images.length == 0) {
          uni.showToast({
            title: "请上传附件",
            icon: 'none',
            mask: true,
            duration: 1500,
          })
          return
        }
        console.log("formLine", this.formLine);
        await reqApi.setFeedback(this.formLine);
        uni.showToast({
          title: "提交成功",
          icon: 'none',
          mask: true,
          duration: 1500,
        })
        setTimeout(() => {
          uni.navigateBack({
            delta: 1
          })
        }, 1500)
      },
      getUrls(e) {
        console.log("子组件传过来的图片", e);
        const {
          keyName,
          arr
        } = e;
        this.formLine[keyName] = arr;
        console.log("formLine", this.formLine);
      },
      getUrl(e) {
        const {
          keyName,
          value
        } = e;
        this.formLine[keyName] = value;
      }
    }
  }
</script>

<style lang="scss" scoped>
  .addressActiveTxt {
    color: #222 !important;
  }

  .addressTxt {
    width: 100%;
    height: 96rpx;
    background: #F7F8FA;
    border-radius: 30rpx;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    font-size: 28rpx;
    color: #AAAAAA;
    padding: 30rpx;
    box-sizing: border-box;
    margin-top: 20rpx;
    position: relative;
    .arrowIcon {
      position: absolute;
      width: 40rpx;
      height: 40rpx;
      right: 30rpx;
      top: 30rpx;
    }
  }
  .container {
    width: 100vw;
    height: 100vh;
    background: #fff;

    .main {
      padding: 30rpx;
      box-sizing: border-box;

      .amountInfo {
        margin-bottom: 30rpx;

        .amountInfo-title {
          font-family: PingFang SC, PingFang SC;
          font-weight: bold;
          font-size: 24rpx;
          color: #232323;
        }

        .autn-item-ipt {
          width: 100%;
          height: 96rpx;
          background: #F7F8FA;
          border-radius: 30rpx;
          font-family: PingFang SC, PingFang SC;
          font-weight: 400;
          font-size: 28rpx;
          color: #222;
          padding: 0 30rpx;
          box-sizing: border-box;
          margin-top: 16rpx;
        }

        .styles {
          font-family: PingFang SC, PingFang SC;
          font-weight: 400;
          font-size: 28rpx;
          color: #AAAAAA;
        }
      }

    }

    .footer {
      position: fixed;
      padding: 50rpx 70rpx;
      box-sizing: border-box;
      width: 100%;
      bottom: 0;

      .btn {
        width: 100%;
        height: 96rpx;
        background: linear-gradient( 270deg, #FF3C21 0%, #EA7222 100%);
        border-radius: 92rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: bold;
        font-size: 32rpx;
        color: #FFFFFF;
        text-align: center;
        line-height: 96rpx;
      }
    }
  }
</style>